<template>
	<view>
		<uni-search-bar @input="search" placeholder="搜索任务" bgColor="#fff" />
		<view class="flex align tabs">
			<view :class="act==1?'act':''" @click="toAct(1)">探店任务</view>
			<view :class="act==2?'act':''" @click="toAct(2)">短视频任务</view>
		</view>
		<navigator :url="'/pages/manage/checkList?id='+item.id" hover-class="none" class="list"
			v-for="(item,index) in list" :key="index">
			<view class="list-info1 flex align between">
				<image :src="item.store_text[0].logo"></image>
				<view class="info1-info">
					<view>{{item.title}}</view>
					<view>{{item.create_time}}</view>
				</view>
				<view class="price">去选号</view>
			</view>
			<view class="list-info2 flex align between">
				<view class="nums">
					报名人数<text>{{item.task_apply_count}}</text>
				</view>
				<view class="nums">
					待选人数<text>{{item.task_apply_wait_count}}</text>
				</view>
				<view class="nums">
					通过人数<text>{{item.task_apply_pass_count}}</text>
				</view>
			</view>
		</navigator>
		<uni-load-more :status="status" v-if="!empty" :content-text="loadText"></uni-load-more>
		<xw-empty :isShow="empty" text="暂无数据" textColor="#777777"></xw-empty>
	</view>
</template>

<script>
	import {
		taskListsCompany
	} from '@/api/apiData.js';
	export default {
		data() {
			return {
				totalPage: 1,
				page: 0,
				offset: 10,
				list: [],
				scrollTop: 0,
				empty: false,
				loadText: {
					loadmore: '点击或上拉加载更多',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				status: 'loadmore',
				check_status: 1,
				title: '',
				act: 1
			};
		},
		onLoad() {
			this.getlist()
		},
		onPageScroll(e) {
			const that = this;
			that.scrollTop = e.scrollTop;
		},
		onReachBottom() {
			const that = this;
			that.getlist();
		},
		methods: {
			toAct(a) {
				this.act = a
				this.page = 0
				this.list = []
				this.getlist();
			},
			search(e) {
				this.title = e
				this.page = 0
				this.list = []
				this.getlist();
			},
			async getlist() {
				const that = this;
				const {
					totalPage,
					page,
					offset,
					list,
					title,
					act
				} = that;
				let obj = {
					size: offset,
					page: page + 1,
					title,
					task_type: act == 1 ? 2 : 1,
				};
				that.status = 'loading';
				if (totalPage > page) {
					let result = await taskListsCompany(obj);
					if (result.code == 1) {
						that.page = page + 1;
						if (result.data.total == 0) {
							console.log((888))
							that.empty = true;
							that.status = 'nomore';
							return;
						}
						that.empty = false;
						setTimeout(() => {
							that.status = 'loadmore';
						}, 500);
						that.list = list.concat(result.data.list);
						that.totalPage = Math.ceil(result.data.total / offset);
					}
				} else {
					setTimeout(() => {
						that.status = 'nomore';
					}, 500);
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.tabs {
		font-size: 32rpx;
		font-weight: bold;
		margin:0 24rpx 30rpx;

		view {
			margin-right: 18rpx;
			position: relative;
			padding: 10rpx 0;
		}

		.act::after {
			content: "";
			position: absolute;
			bottom: 0;
			width: 50%;
			left: 25%;
			height: 9rpx;
			background: #FF6543;
			border-radius: 5rpx;
		}
	}

	.list {
		margin: 24rpx;
		padding-bottom: 23rpx;
		background: white;
		border-radius: 12rpx;

		.list-info1 {
			padding: 30rpx;
			border-bottom: solid 1rpx gainsboro;

			image {
				width: 138rpx;
				height: 138rpx;
				border-radius: 12rpx;
			}

			.info1-info {
				margin-left: 20rpx;
				color: #AAAAAA;
				font-size: 26rpx;
				width: 60%;

				view:nth-child(1) {
					font-size: 36rpx;
					font-weight: bold;
					color: #2D2D2D;
					margin-bottom: 46rpx;
				}
			}

			.price {
				background: #FF6543;
				font-size: 28rpx;
				font-weight: bold;
				color: white;
				width: 144rpx;
				height: 63rpx;
				line-height: 63rpx;
				text-align: center;
				border-radius: 12rpx;
			}
		}

		.list-info2 {
			padding-top: 12rpx;

			.nums {
				color: #AAAAAA;
				font-size: 24rpx;
				font-weight: bold;
				flex: 1;
				text-align: center;

				text {
					color: #FF6543;
					margin-left: 20rpx;
				}
			}
		}
	}
</style>